<%@ page language="java" import="java.util.List" pageEncoding="UTF-8"%>
<%@ page import= "com.roadmap.common.BaseConst"%>
<%@ page import="com.roadmap.struts.action.ActionConst"%>
<%@ page import="com.roadmap.common.RdcResourceBundle" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String box = request.getParameter(ActionConst.MESSAGE_BOX_FLAG);
if(box == null || (!box.equals(ActionConst.MESSAGE_BOX_INBOX) && !box.equals(ActionConst.MESSAGE_BOX_SENT))) {
	box = ActionConst.MESSAGE_BOX_INBOX;
}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/> 
<link href="res/css/layout.css" rel="stylesheet" type="text/css" media="all" />
<link href="res/css/sns.css" rel="stylesheet" type="text/css" media="all" />
<link href="res/css/widget.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="res/js/func.js"></script>
<script type="text/javascript" src="res/js/widget.js"></script>
<title>短消息 | <%=RdcResourceBundle.COMPANY_NAME %></title>

</head>

<body>
	<jsp:include page="/admin/myheader.jsp"></jsp:include>
	
	<!-- define the frame for logging on-->
	<div class="mainbody"><div class="manager">
	<jsp:include page="/admin/msg/nav_btns.jsp"/>
	
	<!-- middle part: content -->
	<div class="middle-part">
		<div class="section">
			<div class="title-sp" style="border:none;">短消息</div>
			<div class="navg">
				<ul id="msgBox">
					<li><a id="inbox" href="message.do?act=all&msg=inbox" onfocus="this.blur();">收件箱</a></li>
					<li><a id="sent" href="message.do?act=all&msg=sent" onfocus="this.blur();">发件箱</a></li>
					<li><a href="message.do?act=create" onfocus="this.blur();">发新短消息</a></li>
				</ul>
			</div>
			
			<div class="messages">
				<logic:notPresent name="messages">
				<span class="prompt-message">没有短消息</span>
				</logic:notPresent>
				
				<logic:present name="messages">
					<ul>
						<logic:iterate id="msg" name="messages">
						<bean:define id="msgid" name="msg" property="id"/>
						<bean:define id="dlgid" name="msg" property="dialogId"/>
						<li>
						<% 
						  if(box.equalsIgnoreCase(ActionConst.MESSAGE_BOX_INBOX)) {
						%>
							<bean:define id="disid" name="msg" property="dispatcherId"/>
							<bean:define id="disname" name="msg" property="dispatcherName"/>
							<div class="smallpicture"><a href="aspirant.do?uid=<%=disid %>"><img src="<%=BaseConst.PURIKURA_DIR_SMALL%><%=disid %>.gif" alt="<%=RdcResourceBundle.COMPANY_NAME %>"/></a></div>
							<div class="author">
								<a href="aspirant.do?uid=<%=disid %>"><%=disname%></a><br/><em><bean:write format='yyyy-MM-dd HH:mm' name='msg' property='createdTime'/></em>
								<logic:equal name='msg' property='status' value="<%=String.valueOf(BaseConst.MESSAGE_STATUS_UNREAD) %>"><img src="res/images/logo/newmsg.gif"/></logic:equal>
							</div>
						<% } else { %>
							<bean:define id="userid" name="msg" property="recipientId"/>
							<bean:define id="username" name="msg" property="recipientName"/>
							<div class="smallpicture"><a href="aspirant.do?uid=<%=userid %>"><img src="<%=BaseConst.PURIKURA_DIR_SMALL%><%=userid %>.gif" alt="<%=RdcResourceBundle.COMPANY_NAME %>"/></a></div>
							<div class="author"><img src="res/images/logo/sendmsg.gif"/>&nbsp;<a href="aspirant.do?uid=<%=userid %>"><%=username%></a><br/><em><bean:write format='yyyy-MM-dd HH:mm' name='msg' property='createdTime'/></em></div>
						<%} %>
							<div class="content"><bean:write name='msg' property='content'/></div>
							<div class="action">
								<span><a href='message.do?act=view&id=<%=dlgid %>'>查看</a></span>
							</div>
						</li>
						</logic:iterate>
					</ul>
				</logic:present>
			</div>
		</div>
		
		<jsp:include page="/pagelet/pagingBarPagelet.jsp"/>
	</div>
	
	<!-- right part: -->
	<div class="right-part">
	</div>
	
	</div>
	
	<div class="clear-div"></div>
	</div>
	
	<jsp:include page="/res/jsp/footer.jsp"></jsp:include>

<script type="text/javascript">
	window.onload = function() {
		var box = "<%=box %>";
		var kids = $("msgBox").getElementsByTagName("LI");	
		for (i = 0; i < kids.length; i += 1){
			kids[i].id = (box === kids[i].firstChild.id) ? "selected" : "unselected";
		}
	}
</script>
	
</body>

</html>
